package com.accenture.fd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.accenture.fd.entity.ScreenItemDescriptionEntity;

@Mapper
public interface ScreenItemDescriptionTblDao {

	     @Select("select\r\n" + 
	     		"  Design_type_ID,\r\n" + 
	     		"  Screen_ID,\r\n" + 
	     		"  Section,\r\n" + 
	     		"  Level_CD,\r\n" + 
	     		"  Screen_item_name,\r\n" + 
	     		"  Screen_item_Physics_name,\r\n" + 
	     		"  I_O_CD,\r\n" + 
	     		"  Type_CD,\r\n" + 
	     		"  Attribute_CD,\r\n" + 
	     		"  TAB_CD,\r\n" + 
	     		"  Required,\r\n" + 
	     		"  Range_wide,\r\n" + 
	     		"  Range_small,\r\n" + 
	     		"  Digit_branch,\r\n" + 
	     		"  Number_bar,\r\n" + 
	     		"  Display_format_CD,\r\n" + 
	     		"  Control_condition,\r\n" + 
	     		"  Data_item,\r\n" + 
	     		"  Status_CD, \r\n" +
	     		"  Processing_ID,\r\n" + 
	     		"  Effective_flag,\r\n" + 
	     		"  Version_number\r\n" + 
	     		"from\r\n" + 
	     		"  TB00008\r\n" + 
	     		"where\r\n" + 
	     		"  Screen_ID = #{screenId}"
	     		+ "and Design_type_ID = #{designId}")
	     @Results({
	    	 @Result(column = "Design_type_ID", property = "designTypeId"),
	    	 @Result(column = "Screen_ID", property = "screenId"),
	    	 @Result(column = "Section", property = "section"),
	    	 @Result(column = "Level_CD", property = "levelCd"),
	    	 @Result(column = "Screen_item_name", property = "screenItemName"),
	    	 @Result(column = "Screen_item_Physics_name", property = "screenItemPhysicsName"),
	    	 @Result(column = "I_O_CD", property = "ioCd"),
	    	 @Result(column = "Type_CD", property = "typeCd"),
	    	 @Result(column = "Attribute_CD", property = "attributeCd"),
	    	 @Result(column = "TAB_CD", property = "tabCd"),
	    	 @Result(column = "Required", property = "required"),
	    	 @Result(column = "Range_wide", property = "rangeWide"),
	    	 @Result(column = "Range_small", property = "rangeSmall"),
	    	 @Result(column = "Digit_branch", property = "digitBranch"),
	    	 @Result(column = "Number_bar", property = "numberBar"),
	    	 @Result(column = "Display_format_CD", property = "displayFormatCd"),
	    	 @Result(column = "Control_condition", property = "controlCondition"),
	    	 @Result(column = "Data_item", property = "dataItem"),
	    	 @Result(column = "Status_CD", property = "statusCd"),
	    	 @Result(column = "Processing_ID", property = "processingId"),
	    	 @Result(column = "Effective_flag", property = "effectiveFlag"),
	    	 @Result(column = "Version_number", property = "versionNumber"),
	     })
	     List<ScreenItemDescriptionEntity> getScreenItemDescriptionEntityList(@Param("screenId") String screenId, @Param("designId") String designId);
	     
	     @Delete("delete from TB00008 where Screen_ID = #{screenId} and Design_type_ID = #{designId}")
	     void delFromScreenItemDescriptionTable(@Param("screenId") String screenId, @Param("designId") String designId);
	     
	     @Insert({
	    	 "<script>",
	    	 "insert into TB00008 value ",
	    	 "<foreach collection='entityList' item='entity' index='index' separator=','>",
	    	 "(#{entity.designTypeId},#{entity.screenId},#{entity.section},#{entity.levelCd},#{entity.screenItemName},",
	    	 "#{entity.screenItemPhysicsName},#{entity.ioCd},#{entity.typeCd},#{entity.attributeCd},",
	    	 "#{entity.tabCd},#{entity.required},#{entity.rangeWide},#{entity.rangeSmall},",
	    	 "#{entity.digitBranch},#{entity.numberBar},#{entity.displayFormatCd},#{entity.controlCondition},#{entity.dataItem},",
	    	 "#{entity.statusCd},#{entity.processingId},#{entity.loginDate},#{entity.loginBy},#{entity.updateDate},",
	    	 "#{entity.updatedBy},#{entity.effectiveFlag},#{entity.versionNumber})",
	    	 "</foreach>",
	    	 "</script>"
	    	})
	     void saveScreenItemDescriptionEntityList(@Param(value="entityList") List<ScreenItemDescriptionEntity> screenItemDescriptionEntityList);
}